package com.jhy.controller;

import com.baomidou.lock.annotation.Lock4j;
import com.jhy.core.domain.R;
import com.jhy.system.domain.bo.AddFriendBo;
import com.jhy.system.domain.bo.EditFriendApplyBo;
import com.jhy.system.domain.bo.SysUserLoginBo;
import com.jhy.system.domain.vo.SysUserFriendVo;
import com.jhy.system.service.ISysUserFriendService;
import com.jhy.system.service.ISysUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeoutException;

@RequiredArgsConstructor
@RequestMapping("/friend")
@RestController()
public class SysUserFriendController {


    private final ISysUserFriendService friendService;



    /**
     * 新增好友
     * **/
    @PostMapping("/add")
    @Lock4j(keys = {"#bo.friendUserId"})
    public R<Boolean> add(@RequestBody AddFriendBo bo) throws TimeoutException {
        return R.ok("ok",friendService.add(bo));
    }

    /**
     * 好友申请修改
     * **/
    @PostMapping("/editFriendApply")
    public R<Boolean> editFriendApply(@RequestBody EditFriendApplyBo bo){
        return R.ok("ok",friendService.editFriendApply(bo));
    }

    /**
     * 根据用户名查询用户信息
     * **/
    @GetMapping("/findByUserName")
    public R<SysUserFriendVo> findByUserName(String userName) {
        return R.ok("ok",friendService.findByUserName(userName));
    }

    /**
     * 申请列表
     * **/
    @GetMapping("/applyList")
    public R<List<SysUserFriendVo>> applyList() {
        return R.ok("ok",friendService.applyList());
    }

    /**
     * 已通过好友列表
     * **/
    @GetMapping("/friendList")
    public R<List<SysUserFriendVo>> friendList() {
        return R.ok("ok",friendService.friendList());
    }



}
